//引入接口
import API from '../../config/server'

Page({
  data:{
    skinlist: []
  },
  onLoad()
  {
    this.skinList()
  },
  skinList(){
    let _this = this
    wx.showLoading({
      title: '加载中...',
    })
    wx.request({
      url: API.skinlist,
      method: 'GET',
      data: '',
      dataType: 'json',
      success: (result) => {
        const info = result.data;
        // console.log(info)
        if(info.success){
          _this.setData({
            skinlist: info.data
          })
        }
      },
      fail: (res) => {
       wx.showToast({
         title: '网络错误',
         icon: 'error',
       })
      },
      complete: (res) => {
        wx.hideLoading()
      },
    })
  },
  skinInfo(e){
    wx.showLoading({
      title: '加载中...',
    })
    let url = e.currentTarget.dataset.url
    wx.navigateTo({
      url: `/pages/skinInfo/skinInfo?url=${url}`,
      success: (result) => {},
      fail: (res) => {
        wx.showToast({
          title: '网络错误',
          icon: 'error',
        })
       },
       complete: (res) => {
         wx.hideLoading()
       },
    })
  }
})